<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-area-add">
        <input id="treeId" name="parentId" type="hidden" th:value="${area.parentId}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label ">上级：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" id="treeName" onclick="selectTree()" readonly="true"
                       th:value="${area.parentName}"/>
            </div>
        </div>
<!--        <div class="form-group">
            <label class="col-sm-3 control-label">父节点：</label>
            <div class="col-sm-8">
                <input id="parentId" name="parentId" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">祖节点：</label>
            <div class="col-sm-8">
                <input id="ancestors" name="ancestors" class="form-control" type="text">
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">城市编码：</label>
            <div class="col-sm-8">
                <input id="citycode" name="citycode" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">区域编码：</label>
            <div class="col-sm-8">
                <input name="adcode" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">行政区名称：</label>
            <div class="col-sm-8">
                <input id="name" name="name" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">行政区划级别：</label>
            <div class="col-sm-8">
                <input id="level" name="level" class="form-control" type="text" required>
            </div>
        </div>
       <!-- <div class="form-group">
            <label class="col-sm-3 control-label">创建者：</label>
            <div class="col-sm-8">
                <input id="createBy" name="createBy" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">创建时间：</label>
            <div class="col-sm-8">
                <input id="createTime" name="createTime" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">更新者：</label>
            <div class="col-sm-8">
                <input id="updateBy" name="updateBy" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">更新时间：</label>
            <div class="col-sm-8">
                <input id="updateTime" name="updateTime" class="form-control" type="text">
            </div>
        </div>-->
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "sys/area"
    $("#form-area-add").validate({
        onkeyup: false,
        rules: {
            xxxx: {
                required: true,
            },
        }
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/addDo", $('#form-area-add').serialize());
        }
    }

    function selectTree() {
        var id = $("#treeId").val();
        var options = {
            title: '选择上级',
            width: "380",
            url: prefix + "/selectTree/" + $("#treeId").val(),
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        if ($.tree.notAllowLastLevel(tree)) {
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    }
</script>
</body>
</html>
